AppleScript

SiteCam is fully AppleScript-savvy. You can change nearly every setting via script. For instance, you can change a caption, switch logos, or take a picture. AppleScript is one of the most powerful features built into the MacOS.

If you're unfamiliar with AppleScript, you can find more information on Apple's AppleScripting site. You can also just try running the AppleScript examples that came with SiteCam. An excerpt of the SiteCam AS dictionary is also worth browsing.

To change most information, you must specify a document. You can specify the document by name, index or by using the term "active document". The "active document" points to the document that was last used or that is about to take a picture. The active document lets you have a pre- or post-process script used by any document.

The sample AppleScripts that come with SiteCam use the term "active document" to keep things simple--but if you have two or more documents that need to be referenced, to avoid ambiguity, reference the document by name. For instance, say you have two SiteCam documents, one that takes a picture that is 640x480 named "large", and another that takes a picture that is 320x240, named "medium". To set the jpeg quality of the document "large", specify an applescript such as:

tell application "SiteCam"
set image quality of document "large" to highest
end tell

SiteCam also has pre- and post-AppleScript processing. These are compiled text files that execute immediately before or after taking a picture. These files are compiled when the document is started, or when the setup is changed (by AppleScript or by setup dialogs). This means that if you change the contents of a script text file, you will need to stop, then start the periodic capture for the SiteCam document.

The standard SiteCam installation package includes sample scripts that show how to control SiteCam via script. It also contains some sample scripts that demonstrate FTP using Anarchie and Fetch, two popular FTP applications.

AppleScript Commands

show preview window: shows WebCam preview window
	show preview window  document  -- the document

hide preview window: shows WebCam preview window
	hide preview window  document  -- the document

take picture with: document to use
	take picture with  reference  -- the document to use
		[type  type class]
		[as  alias]  -- dest
		[renaming file  boolean]  -- false to prevent a file from being overwritten by itself
		[ftp  boolean]  -- false to prevent an FTP file transfer

add frame: add frame to open movie file
	add frame  document  -- the document

create new movie: create new movie
	create new movie  document  -- the document
		as  alias  -- dest

save movie: save existing QuickTime movie
	save movie  document  -- the document

kill movie: dispose of current movie
	kill movie  document  -- the document

Class application: An application program

Plural form:
	applications
Elements:
	window by numeric index, by name
	document by numeric index, by name
	digitizer by numeric index, by name
Properties:
	active document  document  [r/o]  -- the active document
	allow streaming  boolean  -- allow streaming globally
	current video streams  integer  [r/o]  -- total number of streams
	total maximum streams  integer  -- total number of streams allowed
	bytes per second  small real  [r/o]  -- current bytes/second
	images per second  small real  [r/o]  -- current images/second

Class document: a document

Plural form:
	documents
Elements:
	window by numeric index, by name
	caption by numeric index
	logo
	background
Properties:
	images  integer  -- number of images to archive
	file name  string  -- The destination file name
	file extension  string  -- The destination file name
	interval  small integer  -- The number of seconds between images
	quicktime frames  small integer  -- The number of seconds between images
	modified  boolean  [r/o]  -- Has the document been modified since the last save?
	name  international text  [r/o]  -- the title of the document
	active  boolean  -- Document turned on?
	image quality  lossless/highest/high/medium/low/lowest  -- Image quality of JPEG image
	image type  JPEG/PICT/gif/QuickTime  -- Image kind
	width  small integer  -- width
	height  small integer  -- height
	depth  small integer  -- depth
	video orientation  normal/rotate right/rotate left/inverted  -- the video orientation
	pictures taken  small integer  [r/o]  -- pictures taken since start
	preprocess AppleScript file  alias  -- pre-process AppleScript file
	postprocess AppleScript file  alias  -- post-process AppleScript file
	AddFrame AppleScript file  alias  -- post-process AppleScript file
	last image file  alias  -- file of last picture
	brightness level  small integer  -- auto brightness level
	video refresh rate  small integer  -- refresh rate (0-100)
	auto brightness  boolean  -- use auto brightness?
	video refresh  boolean  -- use video refresh
	preview refresh rate  boolean  -- preview refresh rate (ticks)
	next file index  integer  -- next file index (for unrenamed file mode)
	allow CGI access  boolean
	allow server push  boolean
	CGI file mode  boolean
	client images per minute  small integer
	total images per minute  small integer
	number of server push images  small integer
	max server push connections  small integer
	max connection time  integer
	live images  integer  [r/o]  -- live images sent by plugin
	live clients  integer  [r/o]  -- number of clients receiving live video
	ftp in progress  boolean  [r/o]  -- is FTP active
	ftp active  boolean  -- is FTP active
	ftp rename  boolean  -- is FTP rename on
	ftp user name  string  -- FTP user name
	ftp password  string  -- FTP user name
	ftp path  string  -- FTP user name
	ftp host  string  -- FTP host
	ftp good count  integer  [r/o]  -- number of good FTP transfers for this document
	ftp bad count  integer  [r/o]  -- number of bad FTP transfers for this document
	ftp skipped count  integer  [r/o]  -- number of skipped FTP transfers for this document
	ftp broken count  integer  [r/o]  -- number of aborted FTP transfers for this document

Class digitizer: the video digitizer image

Properties:
	hue  integer  -- hue
	brightness  integer  -- brightness
	saturation  integer  -- saturation
	contrast  integer  -- contrast
	sharpness  integer  -- sharpness
	black level  integer  -- black level
	white level  integer  -- white level
	input  small integer  -- input - e.g. 1 or 2
	number of inputs  small integer  [r/o]  -- input - e.g. 1 or 2
	tuner frequency  integer  -- TV Tuner Frequency

Class window: A window

Plural form:
	windows
Properties:
	bounds  bounding rectangle  -- the boundary rectangle for the window
	closeable  boolean  [r/o]  -- Does the window have a close box?
	titled  boolean  [r/o]  -- Does the window have a title bar?
	index  integer  -- the number of the window
	floating  boolean  [r/o]  -- Does the window float?
	modal  boolean  [r/o]  -- Is the window modal?
	name  international text  [r/o]  -- the title of the window
	position  point  [r/o]  -- upper left coordinates of window
	resizable  boolean  [r/o]  -- Is the window resizable?
	zoomable  boolean  [r/o]  -- Is the window zoomable?
	zoomed  boolean  -- Is the window zoomed?
	visible  boolean  -- Is the window visible?

Class caption: A caption
Properties:
	position  point  -- coordinates of caption
	style  plain/bold/italic/underline/outline/shadow/condensed/expanded  -- the text style
	drawing mode  normal/background/invert/gray_blend/shadow 1/shadow 2/overlay 1/overlay 2  -- the drawing mode
	orientation  across/up/down  -- the text orientation
	message  string  -- the text of the caption
	font  string  -- the name of the font
	size  fixed  -- the font size in points
	forecolor  RGB color  -- the foreground color
	backcolor  RGB color  -- the background color for shadow and overlay modes
	horizontal justification  left/right/center/other  -- horizontal justification
	vertical justification  top/bottom/center/other  -- vertical justification

Class logo: the logo image

Properties:
	position  point  -- coordinates of logo
	pict file  alias  -- the picture file
	active  boolean  -- Is the logo currently active?
	horizontal justification  left/right/center/other  -- horizontal justification
	vertical justification  top/bottom/center/other  -- vertical justification
	transfer mode  normal/transparent/inverse/black background/fade in gray  -- transfer mode

Class background: the background image

Properties:
	video offset  point  -- offset of background image
	pict file  alias  -- the picture file
	active  boolean  -- Is the background currently active?
	transfer mode  normal/transparent/inverse/black background/fade in gray  -- transfer mode